var _ajax = require('../../utils/ajax');
var _Server = require('../../utils/server');
var WxParse = require('../../wxParse/wxParse'); // 富文本转化插件
Page({

    /**
     * 页面的初始数据
     */
    data: {

    },

    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function(options) {
        var that = this;
        _ajax.courseInfo(options.articleId, function(data) {
            if(data.code == 0){
                var data = data.data;
                that.setData({
                    courseInfo: data,
                    indexUrl: _Server.url
                });
                var article = data.content;
                WxParse.wxParse('article', 'html', article, that, 5);
            } else {
                wx.showToast({
                    title: data.msg,
                    icon: 'loading'
                });
                setTimeout(function () {
                    wx.navigateBack({
                        delta: 1
                    });
                }, 1500);
            }
        }, this);
    }
})